home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 2 / Amiga Tools 2.iso / tools / gedscripts / pastex / start_tex.ged < prev    next >
Text File  |  1995-03-09  |  3KB  |  139 lines

  1. /*RX
  2.  * AREXX        Name:Start_TeX.ced      Version:1.41    Date:27-Jul-91
  3.  *
  4.  This AREXX script saves and compiles the current CED view. The only
  5. (optional) argument is the format to be used. A '?' formatname will
  6. interactively ask for the format to use.
  7.  *
  8.  A command is send to the TeX server to compile the file. Hence a
  9. return value of 0 does not mean that the file compiled well, but only
  10. that the command was sent to the server and replied to.
  11.  *
  12. AUTHOR:
  13.  *      J\"org H\"ohle, March 91
  14.  *
  15. BUGS:
  16.  virtex doesn't like filenames with blanks (and ARexx parses them
  17. hardly too), so avoid them in file, directory *and* device names.
  18.  *
  19.  Does not like names relative to the local root, like ":foo/bar"
  20.  *
  21. FILES:
  22.  ENV:TEXFORMAT: default format used
  23.  REXX:namestruc
  24.  *
  25.  */
  26.  
  27. address "GOLDED.1"
  28. /* OPTIONS FAILAT 3 */
  29.  
  30. /**
  31.  
  32.  
  33.  
  34. IF ~SHOW('L','rexxsupport.library') THEN
  35.         IF ~ADDLIB('rexxsupport.library',0,-30,0) THEN DO
  36.                 'REQUEST TITLE="Oh Shit!" BODY="Can't open rexxsupport.library!"'
  37.                 EXIT 20
  38.                 END
  39. **/
  40.  
  41. OPTIONS RESULTS
  42. LOCK CURRENT
  43. portname = 'Start_TeX'
  44. script   = 'TeX-server.rexx'    /* no path required, message only       */
  45.  
  46. IF "" = GETCLIP("TEXQUERY") THEN askformat = 0
  47. ELSE askformat = 1              /* ask interactively for format name    */
  48.  
  49. PARSE ARG format .
  50. IF "?" = format THEN DO
  51.         askformat= 1
  52.         format   = ""
  53.         END
  54. ELSE IF '&' = LEFT(format,1) THEN
  55.         format = SUBSTR(format,2)
  56.  
  57. 'REQUEST HIDE=1'
  58.  
  59. QUERY FILE       /* full filename */
  60. filename=RESULT
  61. QUERY PATH
  62. pathname=RESULT
  63.  
  64. 'REQUEST DEFAULT=1'
  65.  
  66. /* We need an absolute name */
  67.  
  68. IF "" == filename | UPPER(RIGHT(filename,3)) ~= "TEX" THEN DO
  69.         'REQUEST TITLE="Beware!" BODY="Sorry, filename must have an extension and end in tex."'
  70.         UNLOCK
  71.         EXIT 5
  72.         END
  73.  
  74. if (RIGHT(pathname,1)) ~= ":" THEN DO
  75.         pathname = pathname||"/"
  76.         END
  77.  
  78. fullname=pathname||filename
  79.  
  80. 'QUERY MODIFY'
  81.  
  82. if (RESULT = 'TRUE') THEN DO
  83.     SAVE ALL
  84.     END
  85.  
  86. IF (SHOW('P', portname)) THEN DO
  87.         /* set the default format, modify it to suit your needs */
  88.         envformat = mygetenv("TEXFORMAT")
  89.         IF "" == format THEN DO
  90.             format = envformat
  91.             IF askformat | "" = envformat THEN DO
  92.                 IF "" = format THEN format = 'plain'
  93.  
  94.                 'REQUEST TITLE="Question!" BODY="Which format to use ?" STRING'
  95.                 nformat=RESULT
  96.                 /* "RESULT" if cancelled */
  97.                 IF "RESULT" ~= nformat THEN format = nformat
  98.  
  99.                 END /* askformat */
  100.             END /* format */
  101.  
  102.         /* If the server is already busy with some compilation, this will
  103.         wait till compilation finishes, this may take a long time */
  104.         /* no unlocking (like in MG) available */
  105.  
  106.         if format ~= envformat THEN CALL mysetenv("TEXFORMAT",format)
  107.  
  108.         UNLOCK
  109.         ADDRESS VALUE portname
  110.         'compile' format fullname
  111.         END
  112. ELSE DO
  113.         /* The TeX server must be started first */
  114.         'REQUEST TITLE="Warning!" BODY="The TeX server script is not running !"'
  115.         UNLOCK
  116.         EXIT 5
  117.         END
  118. EXIT
  119.  
  120.  
  121.  
  122. mygetenv: procedure     /* when will ARexx supply GetEnv/SetEnv ? */
  123.    PARSE ARG name
  124.  
  125.    IF open(TEMPFILE,"ENV:"||name,'r') THEN DO
  126.         gives = readln(TEMPFILE)
  127.         CALL close TEMPFILE
  128.         END
  129.    ELSE gives = ""
  130.  
  131.    RETURN gives
  132.  
  133. mysetenv: procedure
  134.    PARSE ARG name,content
  135.  
  136.    ADDRESS COMMAND "SetEnv" name content
  137.  
  138.    RETURN
  139.